﻿@{
    Layout = null;
}
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml">
<head>
    <meta http-equiv="Content-Type" content="text/html; charset=utf-8" />
    <meta name="renderer" content="webkit|ie-comp|ie-stand" />
    <meta http-equiv="X-UA-Compatible" content="IE=edge,chrome=1" />
    <meta http-equiv="Cache-Control" content="no-siteapp" />
    <link href="~/assets/css/bootstrap.min.css" rel="stylesheet" />
    <link rel="stylesheet" href="~/css/style.css" />
    <link href="~/assets/css/codemirror.css" rel="stylesheet" />
    <link rel="stylesheet" href="~/assets/css/ace.min.css" />
    <link rel="stylesheet" href="~/font/css/font-awesome.min.css" />
    <link rel="stylesheet" href="~/assets/laydate/need/laydate.css" />
    <!--[if lte IE 8]>
      <link rel="stylesheet" href="assets/css/ace-ie.min.css" />
    <![endif]-->
    <script src="~/Scripts/jquery-1.9.1.min.js"></script>
    @*<script src="~/Scripts/jquery-3.3.1.min.js"></script*@>
    <script src="~/assets/js/bootstrap.min.js"></script>
    <script src="~/assets/js/typeahead-bs2.min.js"></script>
    <script src="~/assets/js/jquery.dataTables.min.js"></script>
    <script src="~/assets/js/jquery.dataTables.bootstrap.js"></script>
    <script src="~/assets/layer/layer.js" type="text/javascript"></script>
    <script src="~/assets/laydate/laydate.js" type="text/javascript"></script>
    <script src="~/Scripts/Format.js" type="text/javascript"></script>
    <link rel="stylesheet" href="~/layui-v2.5.4/layui/css/layui.css" />
    <script src="~/layui-v2.5.4/layui/layui.js"></script>
    <title>配送地址管理</title>
</head>
<body>
    <div class="margin clearfix">
        <div class="" id="Other_Management">
            <div class="search_style">
                <ul class="search_content clearfix">
                    <li><label class="l_f">会员名称</label><input name="" type="text" id="name" class="text_add" placeholder="输入会员名称、电话、邮箱" style=" width:400px" /></li>
                    <li style="width:90px;"><button type="button" class="btn_search" id="checkName"><i class="fa fa-search"></i>查询</button></li>
                </ul>
            </div>
            <div class="border clearfix">
                <span class="l_f">
                    <a href="javascript:ovid()" class="btn btn-danger" id="batchDelete"><i class="fa fa-trash"></i>&nbsp;批量删除</a>
                </span>
                @*<span class="r_f">共：<b>2345</b>条</span>*@
            </div>
            <div class="list_style">
                <table class="layui-hide" id="sample-table" lay-filter="demo"></table>
                @*<table class="table table-striped table-bordered table-hover" id="sample-table" lay-filter="demo"> </table>*@
                <script id="barDemo" type="text/html">
                    <a class="layui-btn layui-btn-xs" lay-event="edit">编辑</a>
                    <a class="layui-btn layui-btn-danger layui-btn-xs" lay-event="Sev" href="/Home/DeliveryAddressAdd">添加</a>
                    <a class="layui-btn layui-btn-danger layui-btn-xs" lay-event="del">删除</a>
                </script>
            </div>
        </div>
    </div>
</body>
</html>
<script>
            //jQuery(function ($) {
            //    var oTable1 = $('#sample-table').dataTable({
            //        "aaSorting": [[1, "desc"]],//默认第几个排序
            //        "bStateSave": true,//状态保存
            //        "aoColumnDefs": [
            //            //{"bVisible": false, "aTargets": [ 3 ]} //控制列的隐藏显示
            //            { "orderable": false, "aTargets": [0, 2, 3, 6] }// 制定列不参与排序
            //        ]
            //    });


            //    $('table th input:checkbox').on('click', function () {
            //        var that = this;
            //        $(this).closest('table').find('tr > td:first-child input:checkbox')
            //            .each(function () {
            //                this.checked = that.checked;
            //                $(this).closest('tr').toggleClass('selected');
            //            });

            //    });
            //});



        /*用户-删除*/
        function member_del(obj, id) {
            layer.confirm('确认要删除吗？', function (index) {
                $(obj).parents("tr").remove();
                layer.msg('已删除!', { icon: 1, time: 1000 });
            });
        }
        //积分浏览
        function integration_history(id) {
            layer.open({
                type: 1,
                title: '积分获取记录',
                area: ['800px', '400px'],
                shadeClose: true,
                content: $('#integration_history'),
            })
            $('#integration_history_list').dataTable({
                "aaSorting": [[1, "desc"]],//默认第几个排序
                "bStateSave": true,//状态保存
                "aoColumnDefs": [{
                    "bSortable": false,
                    "orderable": false,
                    "aTargets": [0, 1]
                }]
            });

        };
        //浏览记录

        function Browse_history(id) {
            layer.open({
                type: 1,
                title: '浏览记录',
                area: ['800px', '400px'],
                shadeClose: true,
                content: $('#Browse_history'),
            })
            $('#Browse_history_list').dataTable({
                "aaSorting": [[1, "desc"]],//默认第几个排序
                "bStateSave": true,//状态保存
                "aoColumnDefs": [{
                    "bSortable": false,
                    "orderable": false,
                    "aTargets": [0, 1]
                }]
            });
        }


        //购物记录
        function Order_history(id) {
            layer.open({
                type: 1,
                title: '购物记录',
                area: ['800px', '400px'],
                shadeClose: true,
                content: $('#Order_history'),
            });
            $('#Order_history_list').dataTable({
                "aaSorting": [[1, "desc"]],//默认第几个排序
                "bStateSave": true,//状态保存
                "aoColumnDefs": [{
                    "bSortable": false,
                    "orderable": false,
                    "aTargets": [0, 1]
                }]
            });
        }


</script>
<script>
     //列表刷新
        function TableReload() {
            var table = layui.table;
            var name = $("#name").val();
            //上述方法等价于
            table.reload('sample-table', {
                where: { //设定异步数据接口的额外参数，任意设
                    name: name              
                }
            });
        }
        //查询按钮点击事件
        $("#checkName").click(function () {
            //调用列表刷新方法
            TableReload(null);
        });
    layui.use('table', function () {
        var table = layui.table
        , form = layui.form;  //启用
        table.render({
            elem: '#sample-table'
            , url: '/DeliveryAddress/GetModulePageList/'
            , cellMinWidth: 80 //全局定义常规单元格的最小宽度，layui 2.2.1 新增
            , cols: [[
                { type: 'checkbox' }
                , { field: 'Delivery_Id', width: 110, align: 'center', title: '地址编号', sort: true }
                , { field: 'User_Id', width: 110, align: 'center', title: '用户编号' }
                , { field: 'Delivery_Zipcode', width: 110, align: 'center', title: '邮编', sort: true }
                , { field: 'Delivery_TelPhone', width: 150, align: 'center', title: '联系电话' }
                , { field: 'Delivery_Name', width: 100, align: 'center', title: '收件人名' }
                , { field: 'Delivery_Adress', width: 150, align: 'center', title: '配送地址' }
                , { field: 'Delivery_CreateTime', width: 150, align: 'center', title: '创建时间', templet: "<div>{{Format(d.Delivery_CreateTime,'yyyy-MM-dd')}}</div>" }
                , { field: 'Delivery_UpdateTime', width: 150, align: 'center', title: '修改时间', templet: "<div>{{Format(d.Delivery_UpdateTime,'yyyy-MM-dd')}}</div>" }
                , { fixed: 'right', title: '操作', width: 208, align: 'center', toolbar: '#barDemo' }
            ]]
            , page: true
            , id: 'sample-table'
        }); 
        //删除
        table.on('tool(demo)', function (obj) {
            var data = obj.data;
            var id = data.Delivery_Id;
            if (obj.event === 'del') {
                //删除的功能代码
                layer.confirm('真的要删除吗', function (index) {
                    $.ajax({
                        url: "/DeliveryAddress/DelMenuId?id=" + id,
                        type: "Post",
                        success: function (data) {
                            if (data.Success) {
                                layer.msg('删除成功！', {
                                    title: '提示框',
                                    icon: 1,
                                    time: 2000

                                }, function () {
                                    TableReload();
                                    //layer.close(index);
                                });
                                location.reload();
                            }
                            else {
                                layer.msg('删除失败！', {
                                    title: '提示框',
                                    icon: 1,
                                    time: 2000
                                });
                            }
                        }
                    });
                });
            } else if (obj.event === 'edit') {
                window.location.href = "/Home/DeliveryAddressUpdate?id=" + id;
            }
        });
        //批量删除
        $("#batchDelete").click(function () {
            //获取复选框集合数据
            var checkStatus = table.checkStatus('sample-table');
            var data = checkStatus.data;
            //获得where限制条件Id
            var codeId = "";
            if (data.length == 0) {
                layer.msg('请选择一行', {
                    title: '提示框',
                    icon: 0,
                    time: 2000
                });
                return;
            };
            //遍历集合,拼接字符串
            for (var i in data) {
                if (i == data.length - 1) {
                    codeId += data[i].Delivery_Id
                } else {
                    codeId += data[i].Delivery_Id + ",";
                }
            };
            //温馨提示是否要删除
            $.ajax({
                url: "/DeliveryAddress/BatchDelete?Id=" + codeId,
                traditional: true,
                type: "post",
                success: function (operate) {
                    if (operate.Success) {

                        layer.msg('批量删除成功!！', {
                            title: '提示框',
                            icon: 1,
                            time: 400
                        })
                        location.reload();//刷新页面
                    }
                    else {
                        layer.msg('批量删除失败！', {
                            title: '提示框',
                            icon: 1,
                            time: 400
                        })
                    }
                }
            })
        })
    });
</script>
